package br.inf.solutions.apresentacoes.ssp.model.bulletin.items;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.annotations.ValidatorClass;
import br.com.vexillum.util.SpringFactory;
import br.inf.solutions.apresentacoes.ssp.control.TransferUnityController;
import br.inf.solutions.apresentacoes.ssp.model.Person;
import br.inf.solutions.apresentacoes.ssp.model.basics.TypeDrive;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.BulletinItem;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.BulletinTopics;
import br.inf.solutions.apresentacoes.ssp.model.hierarchy.HierarchyStructEntity;
import br.inf.solutions.apresentacoes.ssp.model.interfaces.IExistsPerson;

@SuppressWarnings("serial")
@ValidatorClass(validatorClass = "br.inf.solutions.apresentacoes.ssp.control.validator.TransferUnityValidator")
@Entity
@Table(name = "transferunity")
public class TransferUnity extends BulletinItem implements IExistsPerson{
	
	public TransferUnity() {
		super(new BulletinTopics(5l, "TransferUnity", "/paginas/transferenciaunidade/retificacao.zul"));
	}
	
	@Validate(notNull=true)
	@SearchField
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="person_id",insertable=true, updatable=true, unique=false)
	private Person person;

	@Validate(notNull=true)
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="typedrive_id",insertable=true, updatable=true, unique=false)
	private TypeDrive typeDrive;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "unitOld", insertable=true, updatable=false, unique=false)
	private HierarchyStructEntity unitOld;
	
	@SearchField
	@Validate(notNull=true)
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "unitDestiny", insertable=true, updatable=false, unique=false)
	private HierarchyStructEntity unitDestiny;
	
	@Validate(notNull=false)
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "functionDestiny", insertable=true, updatable=false, unique=false)
	private HierarchyStructEntity functionsDestiny;
	
	@Validate(notNull=true)
	@Column(name="datesubmission", insertable=true, updatable=true, unique=false)
	private Date dateSubmission;

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public TypeDrive getTypeDrive() {
		return typeDrive;
	}

	public void setTypeDrive(TypeDrive typeDrive) {
		this.typeDrive = typeDrive;
	}

	public HierarchyStructEntity getUnitDestiny() {
		return unitDestiny;
	}

	public void setUnitDestiny(HierarchyStructEntity unitDestiny) {
		this.unitDestiny = unitDestiny;
	}

	public Date getDateSubmission() {
		return dateSubmission;
	}

	public void setDateSubmission(Date dateSubmission) {
		this.dateSubmission = dateSubmission;
	}

	public HierarchyStructEntity getUnitOld() {
		return unitOld;
	}

	public void setUnitOld(HierarchyStructEntity unitOld) {
		this.unitOld = unitOld;
	}

	public HierarchyStructEntity getFunctionsDestiny() {
		return functionsDestiny;
	}

	public void setFunctionsDestiny(HierarchyStructEntity functionsDestiny) {
		this.functionsDestiny = functionsDestiny;
	}
	
	@Override
	public TransferUnityController getControl() {
		return SpringFactory.getController("transferUnityController", TransferUnityController.class, null);
	}
}
